#pragma once
#include <boost/asio.hpp>
#include <string>

#include "DateBase.hpp"
#include "Session.hpp"

namespace MRMDS::Server
{
class Server
{
  public:
    bool LoadConfig();
    void InitService(DataBase::SharePtr db, int port);
    void Run();

  private:
    boost::asio::io_context ioctx;
    std::unique_ptr<boost::asio::ip::tcp::acceptor> acceptor;
    DataBase::SharePtr db;

    void Accept();
    void OnAcceptClient(Session::SharePtr session, const boost::system::error_code &error);
};
} // namespace MRMDS::Server